package com.cy.pj.sys.dao;

import com.cy.pj.sys.pojo.Role;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface RoleDao {
    /**
     * 根据姓名查询
     * @param name
     * @return
     */
    List<Role> selectRole(String name);
    /**
     * 根据id删除多条数据
     */
    int deleteRoleById(Integer[] ids);

    /**
     * 新增角色
     * @param role
     * @return
     */
    @Insert("insert into t_role(id,name) values(null,#{name})")
    int insertRole(Role role);

    /**
     * 根据ID查询角色信息
     * @param id
     * @return
     */
    @Select("select * from t_role where id=#{id}")
    Role selectRoleById(Integer id);

    @Update("update t_role set name=#{name} where id=#{id}")
    int updateRoleById(Role role);

}
